001 /**
002 * Created by IntelliJ IDEA.
003 * User: Wei Wang
004 * Date: Feb 26, 2003
005 * Time: 7:58:18 PM
006 */
007
008 package EVolve.util.painters.placements;
009
010 import EVolve.visualization.*;
011 import EVolve.util.painters.shapes.Shape;
012 import EVolve.util.painters.shapes.*;
013 import EVolve.exceptions.NoDataPlotException;
014
015 import java.util.HashMap;
016 import java.util.ArrayList;
017 import java.awt.*;
018
019 public abstract class Placement{
020 public static final int INDENT = 50;
021 protected int shapeSize = 10;
022 protected HashMap parties[];
023
024 public Placement() {
025 parties = new HashMap[2];
026 }
027
028 public void categoritize(AutoImage image, int consumer_type) {
029 int w = image.getW(), h = image.getH();
030
031 parties[0] = new HashMap();
032 parties[1] = new HashMap();
033
034 for (int j=0; j<h; j++) {
035 for (int i=0; i<w; i++) {
036 Object value = image.getColor(i,j);
037 if (value == null) continue;
038 for (int k=0; k<((ArrayList)value).size(); k++) {
039 Shape consumer = (Shape)((ArrayList)value).get(k);
040 if (consumer.getEntityType() == consumer_type) {
041 parties[1].put(new Integer(parties[1].size()),consumer);
042 break;
043 }
044 }
045 }
046 }
047
048
049 for (int i=0; i<w; i++) {
050 for (int j=0; j<h; j++) {
051 Object value = image.getColor(i,j);
052 if (value == null) continue;
053 for (int k=0; k<((ArrayList)value).size(); k++) {
054 Shape producer = (Shape)((ArrayList)value).get(k);
055 if (producer.getEntityType() != consumer_type) {
056 parties[0].put(new Integer(parties[0].size()),producer);
057 break;
058 }
059 }
060 }
061 }
062
063 }
064
065 public abstract String getName();
066
067 public abstract Rectangle initialPlacement(AutoImage image) throws NoDataPlotException;
068 }